package com.example.administrator.yuejian2.model;

import com.example.administrator.yuejian2.RetrofitListener.RetrofitListener;
import com.example.administrator.yuejian2.bean.DeleteOrderBean;
import com.example.administrator.yuejian2.service.DeleteTrainOrderService;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

import static com.example.administrator.yuejian2.other.Url.BASEURL;
import static com.example.administrator.yuejian2.other.Url.URL1;

public class DeleteMyTrainOrderModel {


    private Retrofit retrofit;
    private DeleteTrainOrderService deleteTrainOrderService;


    public DeleteMyTrainOrderModel()
    {
        retrofit=new Retrofit.Builder()
                .baseUrl(BASEURL+URL1)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        deleteTrainOrderService=retrofit.create(DeleteTrainOrderService.class);
    }
    public void deleteTrainOrder(String trainorder_id, String user_id, final RetrofitListener listener)
    {
        Call<DeleteOrderBean> call=deleteTrainOrderService.deleteOrder(trainorder_id,user_id);
        call.enqueue(new Callback<DeleteOrderBean>() {
            @Override
            public void onResponse(Call<DeleteOrderBean> call, Response<DeleteOrderBean> response) {
                listener.onSuccess(response.body(),1);
            }

            @Override
            public void onFailure(Call<DeleteOrderBean> call, Throwable t) {
                listener.onFail();
            }
        });
    }
}
